<?php

/**
 * This is the model class for table "subarea".
 *
 * The followings are the available columns in table 'subarea':
 * @property integer $id
 * @property double $lat
 * @property double $lng
 * @property string $title
 * @property string $description
 * @property string $adds
 * @property string $hotline
 * @property integer $evaluation
 * @property integer $percost
 * @property string $createtime
 */
class Subarea extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Subarea the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'subarea';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('title', 'required'),
			array('evaluation, percost, companyid', 'numerical', 'integerOnly'=>true),
			array('lat, lng', 'numerical'),
			array('title, description, adds, hotline', 'length', 'max'=>255),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, lat, lng, title, description, adds, hotline, evaluation, percost, createtime', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'lat' => 'Lat',
			'lng' => 'Lng',
			'companyid' => '总公司',
			'title' => '标题',
			'description' => '介绍',
			'adds' => '地址',
			'hotline' => '热线',
			'evaluation' => '评价',
			'percost' => '参考价',
			'createtime' => '创建时间',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('lat',$this->lat);
		$criteria->compare('lng',$this->lng);
		$criteria->compare('title',$this->title,true);
		$criteria->compare('description',$this->description,true);
		$criteria->compare('adds',$this->adds,true);
		$criteria->compare('hotline',$this->hotline,true);
		$criteria->compare('evaluation',$this->evaluation);
		$criteria->compare('percost',$this->percost);
		$criteria->compare('createtime',$this->createtime,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}